home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / lang / c++-part2 / 17340 < prev    next >
Encoding:
Text File  |  1996-08-05  |  1.7 KB  |  64 lines

  1. Path: zippy.dct.ac.uk!str-ccsun!strath-cs!st-and!usenet
  2. Newsgroups: comp.os.ms-windows.programmer.tools.mfc,comp.lang.c++
  3. Subject: Re: Controls in non-dialog (mfc)
  4. Message-ID: <317236F8.1211@st-andrews.ac.uk>
  5. From: William Heitler <wjh@st-andrews.ac.uk>
  6. Date: Mon, 15 Apr 1996 11:46:00 +0000
  7. References: <4k81um$s8t@pub.news.uk.psi.net>
  8. Organization: University of St Andrews
  9. NNTP-Posting-Host: bgpc-wjh.st-and.ac.uk
  10. Mime-Version: 1.0
  11. Content-Type: text/plain; charset=us-ascii
  12. Content-Transfer-Encoding: 7bit
  13. X-Mailer: Mozilla 2.0 (Win95; I)
  14.  
  15. andrew oxenburgh wrote:
  16. > sj2393@ansys.com (Steve Jones) writes:
  17. > > How in MFC does one go about embedding a control within a
  18. > > window that is not a dialog box?  For example, I can
  19. > > construct and Create() a CEdit object within a CView derived
  20. > > class, but nothing (apparently) happens.  I knew when I
  21. > > tried it something wasn't quite right; I wasn't sure what to
  22. > > use for the nID.  Is it necessary to use a resource?
  23. > >
  24. > >
  25. > > steve
  26. > >
  27. > > stevejones@ansys.com
  28. > >
  29.  
  30. So far as I know the nID can be anything you like. To have it come up visible at the start don't 
  31. forget to set WS_VISIBLE in the Create.
  32. I have:
  33.  
  34. in *.h
  35. class CVertAxis : public CWnd        // the containing class (could be from CView)
  36. {
  37. .
  38. .
  39.     CEdit TopScale;        // embedded edit control
  40. .
  41. .
  42.     // Generated message map functions
  43. protected:
  44.     //{{AFX_MSG(CVertAxis)
  45.     afx_msg int OnCreate(LPCREATESTRUCT lpCreateStruct);
  46. .
  47. .
  48. and in *.cpp
  49.  
  50. int CVertAxis::OnCreate(LPCREATESTRUCT lpCreateStruct)
  51. {
  52. .
  53. .
  54.     if (!TopScale.Create(WS_CHILD|WS_VISIBLE|WS_TABSTOP|
  55.         ES_MULTILINE | ES_RIGHT, rect1, this, IDC_TOPSCALE))
  56.     {
  57.         TRACE("Failed to create TopScale in CVertAxis");
  58.         return -1;
  59.     }
  60. .
  61. .
  62. Hope this helps.
  63.